<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});

Route::group([
    'namespace'  => 'App\Api\Controllers',
], function () {

    Route::get('categories',[\App\Api\Controller\CategoryController::class,'index'])->name('categories.index');
    Route::get('greetings',[\App\Api\Controller\GreetingController::class,'index'])->name('greetings.index');
    Route::get('greetings/{id}',[\App\Api\Controller\GreetingController::class,'show'])->name('greetings.show');
    Route::get('search',[\App\Api\Controller\GreetingController::class,'search'])->name('greetings.search');
    Route::post('greetings/{id}/copy',[\App\Api\Controller\GreetingController::class,'copy'])->name('greetings.copy');
});

Route::group([
    'namespace'  => 'App\Api\Controllers',
    'middleware' => 'api',
    'prefix' => 'auth'
], function () {
    Route::post('verifyCode', [\App\Api\Controller\AuthController::class,'verifyCode'])->name('auth.verifyCode');
    Route::post('login', [\App\Api\Controller\AuthController::class,'login']);
    Route::post('logout', [\App\Api\Controller\AuthController::class,'logout']);
    Route::post('refresh', [\App\Api\Controller\AuthController::class,'refresh']);
    Route::post('me', [\App\Api\Controller\AuthController::class,'me']);
});

